﻿using Microsoft.Extensions.DependencyInjection;
using Modules.Template.Repositories;
using PmSoft;

namespace Modules.Template
{
    [UseDI(ServiceLifetime.Scoped)]
    public class TemplateService
    {
        private readonly TemplateRepository templateRepository;

        public TemplateService(TemplateRepository templateRepository)
        {
            this.templateRepository = templateRepository;
        }

        public IEnumerable<SysTemplate> GetTemplates(模板类型 type)
        {
            return templateRepository.GetAll().Where(a => a.Type == type && a.IsDeleted == false);
        }

        public SysTemplate? GetTemplate(string id)
        {
            return templateRepository.Get(id);
        }
    }
}